package cate.game.role.res.guild.po;

import cate.common.table.d.GDFunc;
import cate.common.table.d.GDGuild;
import cate.game.role.res.guild.GuildFuncBase;
import cate.game.role.res.guild.msg.GuildRecordResp;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import cate.game.role.Role;
import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "公会成员行为记录")
public class GuildRecordPO extends GuildFuncBase {
    @NoteField(value = "公会日志列表")
    public List<GuildLogDetailPO> list;

    @Override
    public void initialize(GuildPO guild) {
        super.initialize(guild);
        if (list == null) {
            list = new ArrayList<>();
        }
    }

    /** 添加公会日志 */
    @JsonIgnore
    public void addRecord(GuildLogDetailPO record) {
        if (list.size() >= GDGuild.basic.RECORD_NUM_MAX) {
            list.remove(list.size() - 1);
        }
        list.add(0, record);
        //不需要实时通知
    }

    /** 公会日志列表通知 */
    @JsonIgnore
    public void noticeUpdate(Role role) {
        role.sendNow(new GuildRecordResp(this));
    }

    @Override
    public int getFuncId() {
        return GDFunc.GuildFunc.MEMBER;
    }
}
